(defun move-rect! (rect direct &optional (n 1))
    (case direct
      (:up    (decf (sdl2:rect-y rect) n))
      (:down  (incf (sdl2:rect-y rect) n))
      (:right (incf (sdl2:rect-x rect) n))
      (:left  (decf (sdl2:rect-x rect) n))))

(defparameter *screen-width*  640)
(defparameter *screen-height* 480)

(defun game ()
        (sdl2:with-init (:video)
            (sdl2:with-window (win :title "Симуляция броуновского движения"
                                   :w *screen-width*
                                   :h *screen-height*
                                   :flags '(:shown :resizable))
                (let ((scr-sur    (sdl2:get-window-surface win))
                      (rect (sdl2:make-rect 100 100 64 64)))
                    (sdl2:with-event-loop ()
                        (:quit () t)
                        (:keydown (:keysym key)
                                  (case (sdl2:scancode key)
                                    (:scancode-up    (move-rect! rect :up))
                                    (:scancode-down  (move-rect! rect :down))
                                    (:scancode-left  (move-rect! rect :left))
                                    (:scancode-right (move-rect! rect :right))
                                    (t :default))
                                  )
                        (:idle ()
                               (setf scr-sur (sdl2:get-window-surface win))
                               (sdl2:fill-rect scr-sur
                                               nil
                                               (sdl2:map-rgb (sdl2:surface-format scr-sur) 10 160 100))
                               (sdl2:fill-rect scr-sur
                                               rect
                                               (sdl2:map-rgb (sdl2:surface-format scr-sur) 10 16 100))

                               (sdl2:update-window win)))))))
